// ------------------------------------------------------------
// Copyright (c) Microsoft Corporation.  All rights reserved.
// Licensed under the MIT License (MIT). See License.txt in the repo root for license information.
// ------------------------------------------------------------

namespace FabricDCA.Test
{
    using System;
    using System.Linq;
    using System.IO;
    using Microsoft.VisualStudio.TestTools.UnitTesting;
    using Tools.EtlReader;
    using System.Text;

    /// <summary>
    /// Provides unit tests for the <see cref="EtlReaderTests"/> class.
    /// </summary>
    [TestClass]
    public class EtlReaderTests
    {
        private byte[] manifestInBytes =
        {
            0x3c, 0x69, 0x6e, 0x73, 0x74, 0x72, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e,
            0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x20, 0x78, 0x6d, 0x6c, 0x6e, 0x73, 0x3d, 0x22,
            0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x73, 0x2e, 0x6d,
            0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x77, 0x69, 0x6e,
            0x2f, 0x32, 0x30, 0x30, 0x34, 0x2f, 0x30, 0x38, 0x2f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x22,
            0x3e, 0x0d, 0x0a, 0x20, 0x3c, 0x69, 0x6e, 0x73, 0x74, 0x72, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61,
            0x74, 0x69, 0x6f, 0x6e, 0x20, 0x78, 0x6d, 0x6c, 0x6e, 0x73, 0x3a, 0x78, 0x73, 0x3d, 0x22, 0x68,
            0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x77, 0x33, 0x2e, 0x6f, 0x72, 0x67,
            0x2f, 0x32, 0x30, 0x30, 0x31, 0x2f, 0x58, 0x4d, 0x4c, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x22,
            0x20, 0x78, 0x6d, 0x6c, 0x6e, 0x73, 0x3a, 0x78, 0x73, 0x69, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70,
            0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x77, 0x33, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x32, 0x30,
            0x30, 0x31, 0x2f, 0x58, 0x4d, 0x4c, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x2d, 0x69, 0x6e, 0x73,
            0x74, 0x61, 0x6e, 0x63, 0x65, 0x22, 0x20, 0x78, 0x6d, 0x6c, 0x6e, 0x73, 0x3a, 0x77, 0x69, 0x6e,
            0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73,
            0x74, 0x73, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x2e, 0x63, 0x6f, 0x6d,
            0x2f, 0x77, 0x69, 0x6e, 0x2f, 0x32, 0x30, 0x30, 0x34, 0x2f, 0x30, 0x38, 0x2f, 0x77, 0x69, 0x6e,
            0x64, 0x6f, 0x77, 0x73, 0x2f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x3e, 0x0d, 0x0a, 0x20,
            0x20, 0x3c, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x20, 0x78, 0x6d, 0x6c, 0x6e, 0x73, 0x3d, 0x22,
            0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x73, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x73, 0x2e, 0x6d,
            0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x77, 0x69, 0x6e,
            0x2f, 0x32, 0x30, 0x30, 0x34, 0x2f, 0x30, 0x38, 0x2f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x22,
            0x3e, 0x0d, 0x0a, 0x3c, 0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x20, 0x6e, 0x61, 0x6d,
            0x65, 0x3d, 0x22, 0x54, 0x65, 0x73, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x53, 0x6f, 0x75, 0x72,
            0x63, 0x65, 0x22, 0x20, 0x67, 0x75, 0x69, 0x64, 0x3d, 0x22, 0x7b, 0x30, 0x64, 0x34, 0x36, 0x38,
            0x64, 0x38, 0x31, 0x2d, 0x61, 0x37, 0x31, 0x33, 0x2d, 0x34, 0x63, 0x31, 0x36, 0x2d, 0x61, 0x38,
            0x61, 0x33, 0x2d, 0x61, 0x33, 0x64, 0x30, 0x64, 0x33, 0x35, 0x33, 0x35, 0x65, 0x61, 0x65, 0x7d,
            0x22, 0x20, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x4e, 0x61,
            0x6d, 0x65, 0x3d, 0x22, 0x54, 0x65, 0x73, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x53, 0x6f, 0x75,
            0x72, 0x63, 0x65, 0x22, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x46, 0x69, 0x6c, 0x65,
            0x4e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x54, 0x65, 0x73, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x53,
            0x6f, 0x75, 0x72, 0x63, 0x65, 0x22, 0x20, 0x73, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x3d, 0x22, 0x54,
            0x65, 0x73, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x22, 0x3e,
            0x0d, 0x0a, 0x20, 0x3c, 0x74, 0x61, 0x73, 0x6b, 0x73, 0x3e, 0x0d, 0x0a, 0x20, 0x20, 0x3c, 0x74,
            0x61, 0x73, 0x6b, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x54, 0x65, 0x73, 0x74, 0x53, 0x74,
            0x72, 0x75, 0x63, 0x74, 0x75, 0x72, 0x65, 0x64, 0x54, 0x72, 0x61, 0x63, 0x65, 0x30, 0x22, 0x20,
            0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x3d, 0x22, 0x24, 0x28, 0x73, 0x74, 0x72, 0x69, 0x6e,
            0x67, 0x2e, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x54, 0x65, 0x73, 0x74, 0x53, 0x74, 0x72, 0x75, 0x63,
            0x74, 0x75, 0x72, 0x65, 0x64, 0x54, 0x72, 0x61, 0x63, 0x65, 0x30, 0x29, 0x22, 0x20, 0x76, 0x61,
            0x6c, 0x75, 0x65, 0x3d, 0x22, 0x34, 0x32, 0x34, 0x36, 0x37, 0x22, 0x2f, 0x3e, 0x0d, 0x0a, 0x20,
            0x20, 0x3c, 0x74, 0x61, 0x73, 0x6b, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x45, 0x76, 0x65,
            0x6e, 0x74, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22,
            0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x3d, 0x22, 0x24, 0x28, 0x73, 0x74, 0x72, 0x69,
            0x6e, 0x67, 0x2e, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x53, 0x6f, 0x75,
            0x72, 0x63, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x29, 0x22, 0x20, 0x76, 0x61, 0x6c,
            0x75, 0x65, 0x3d, 0x22, 0x36, 0x35, 0x35, 0x33, 0x34, 0x22, 0x2f, 0x3e, 0x0d, 0x0a, 0x20, 0x3c,
            0x2f, 0x74, 0x61, 0x73, 0x6b, 0x73, 0x3e, 0x0d, 0x0a, 0x20, 0x3c, 0x6f, 0x70, 0x63, 0x6f, 0x64,
            0x65, 0x73, 0x3e, 0x0d, 0x0a, 0x20, 0x3c, 0x2f, 0x6f, 0x70, 0x63, 0x6f, 0x64, 0x65, 0x73, 0x3e,
            0x0d, 0x0a, 0x20, 0x3c, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x73, 0x3e, 0x0d, 0x0a, 0x20,
            0x20, 0x3c, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22,
            0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x33, 0x22, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
            0x65, 0x3d, 0x22, 0x24, 0x28, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x6b, 0x65, 0x79, 0x77,
            0x6f, 0x72, 0x64, 0x5f, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x33, 0x29, 0x22, 0x20, 0x6d,
            0x61, 0x73, 0x6b, 0x3d, 0x22, 0x30, 0x78, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
            0x30, 0x30, 0x30, 0x22, 0x2f, 0x3e, 0x0d, 0x0a, 0x20, 0x20, 0x3c, 0x6b, 0x65, 0x79, 0x77, 0x6f,
            0x72, 0x64, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e,
            0x32, 0x22, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x3d, 0x22, 0x24, 0x28, 0x73, 0x74,
            0x72, 0x69, 0x6e, 0x67, 0x2e, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x5f, 0x53, 0x65, 0x73,
            0x73, 0x69, 0x6f, 0x6e, 0x32, 0x29, 0x22, 0x20, 0x6d, 0x61, 0x73, 0x6b, 0x3d, 0x22, 0x30, 0x78,
            0x32, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x22, 0x2f, 0x3e, 0x0d,
            0x0a, 0x20, 0x20, 0x3c, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x20, 0x6e, 0x61, 0x6d, 0x65,
            0x3d, 0x22, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x31, 0x22, 0x20, 0x6d, 0x65, 0x73, 0x73,
            0x61, 0x67, 0x65, 0x3d, 0x22, 0x24, 0x28, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x6b, 0x65,
            0x79, 0x77, 0x6f, 0x72, 0x64, 0x5f, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x31, 0x29, 0x22,
            0x20, 0x6d, 0x61, 0x73, 0x6b, 0x3d, 0x22, 0x30, 0x78, 0x34, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
            0x30, 0x30, 0x30, 0x30, 0x30, 0x22, 0x2f, 0x3e, 0x0d, 0x0a, 0x20, 0x20, 0x3c, 0x6b, 0x65, 0x79,
            0x77, 0x6f, 0x72, 0x64, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x53, 0x65, 0x73, 0x73, 0x69,
            0x6f, 0x6e, 0x30, 0x22, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x3d, 0x22, 0x24, 0x28,
            0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x5f, 0x53,
            0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x30, 0x29, 0x22, 0x20, 0x6d, 0x61, 0x73, 0x6b, 0x3d, 0x22,
            0x30, 0x78, 0x38, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x22, 0x2f,
            0x3e, 0x0d, 0x0a, 0x20, 0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x73, 0x3e, 0x0d,
            0x0a, 0x20, 0x3c, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x3e, 0x0d, 0x0a, 0x20, 0x20, 0x3c, 0x65,
            0x76, 0x65, 0x6e, 0x74, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3d, 0x22, 0x30, 0x22, 0x20, 0x76,
            0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x30, 0x22, 0x20, 0x6c, 0x65, 0x76, 0x65, 0x6c,
            0x3d, 0x22, 0x77, 0x69, 0x6e, 0x3a, 0x4c, 0x6f, 0x67, 0x41, 0x6c, 0x77, 0x61, 0x79, 0x73, 0x22,
            0x20, 0x73, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x3d, 0x22, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x53, 0x6f,
            0x75, 0x72, 0x63, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x20, 0x74, 0x61, 0x73,
            0x6b, 0x3d, 0x22, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4d, 0x65,
            0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x20, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x3d,
            0x22, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4d, 0x65, 0x73, 0x73,
            0x61, 0x67, 0x65, 0x41, 0x72, 0x67, 0x73, 0x22, 0x2f, 0x3e, 0x0d, 0x0a, 0x20, 0x20, 0x3c, 0x65,
            0x76, 0x65, 0x6e, 0x74, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3d, 0x22, 0x32, 0x33, 0x30, 0x36,
            0x37, 0x22, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x30, 0x22, 0x20, 0x6c,
            0x65, 0x76, 0x65, 0x6c, 0x3d, 0x22, 0x77, 0x69, 0x6e, 0x3a, 0x49, 0x6e, 0x66, 0x6f, 0x72, 0x6d,
            0x61, 0x74, 0x69, 0x6f, 0x6e, 0x61, 0x6c, 0x22, 0x20, 0x73, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x3d,
            0x22, 0x54, 0x65, 0x73, 0x74, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x75, 0x72, 0x65, 0x64, 0x54,
            0x72, 0x61, 0x63, 0x65, 0x30, 0x22, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x3d, 0x22,
            0x24, 0x28, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x54,
            0x65, 0x73, 0x74, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x75, 0x72, 0x65, 0x64, 0x54, 0x72, 0x61,
            0x63, 0x65, 0x30, 0x29, 0x22, 0x20, 0x74, 0x61, 0x73, 0x6b, 0x3d, 0x22, 0x54, 0x65, 0x73, 0x74,
            0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x75, 0x72, 0x65, 0x64, 0x54, 0x72, 0x61, 0x63, 0x65, 0x30,
            0x22, 0x2f, 0x3e, 0x0d, 0x0a, 0x20, 0x3c, 0x2f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x3e, 0x0d,
            0x0a, 0x20, 0x3c, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x3e, 0x0d, 0x0a, 0x20,
            0x20, 0x3c, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x20, 0x74, 0x69, 0x64, 0x3d, 0x22,
            0x45, 0x76, 0x65, 0x6e, 0x74, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61,
            0x67, 0x65, 0x41, 0x72, 0x67, 0x73, 0x22, 0x3e, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x3c, 0x64, 0x61,
            0x74, 0x61, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
            0x22, 0x20, 0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x77, 0x69, 0x6e, 0x3a, 0x55, 0x6e,
            0x69, 0x63, 0x6f, 0x64, 0x65, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x22, 0x2f, 0x3e, 0x0d, 0x0a,
            0x20, 0x20, 0x3c, 0x2f, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x3e, 0x0d, 0x0a, 0x20,
            0x3c, 0x2f, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x3e, 0x0d, 0x0a, 0x3c, 0x2f,
            0x70, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x3e, 0x0d, 0x0a, 0x3c, 0x2f, 0x65, 0x76, 0x65,
            0x6e, 0x74, 0x73, 0x3e, 0x0d, 0x0a, 0x3c, 0x2f, 0x69, 0x6e, 0x73, 0x74, 0x72, 0x75, 0x6d, 0x65,
            0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3e, 0x0d, 0x0a, 0x3c, 0x6c, 0x6f, 0x63, 0x61, 0x6c,
            0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3e, 0x0d, 0x0a, 0x20, 0x3c, 0x72, 0x65, 0x73, 0x6f,
            0x75, 0x72, 0x63, 0x65, 0x73, 0x20, 0x63, 0x75, 0x6c, 0x74, 0x75, 0x72, 0x65, 0x3d, 0x22, 0x65,
            0x6e, 0x2d, 0x55, 0x53, 0x22, 0x3e, 0x0d, 0x0a, 0x20, 0x20, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e,
            0x67, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x3e, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x3c, 0x73, 0x74, 0x72,
            0x69, 0x6e, 0x67, 0x20, 0x69, 0x64, 0x3d, 0x22, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x54, 0x65,
            0x73, 0x74, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x75, 0x72, 0x65, 0x64, 0x54, 0x72, 0x61, 0x63,
            0x65, 0x30, 0x22, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3d, 0x22, 0x54, 0x65, 0x73, 0x74, 0x20,
            0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x2f, 0x3e, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x3c,
            0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x20, 0x69, 0x64, 0x3d, 0x22, 0x6b, 0x65, 0x79, 0x77, 0x6f,
            0x72, 0x64, 0x5f, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x30, 0x22, 0x20, 0x76, 0x61, 0x6c,
            0x75, 0x65, 0x3d, 0x22, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x30, 0x22, 0x2f, 0x3e, 0x0d,
            0x0a, 0x20, 0x20, 0x20, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x20, 0x69, 0x64, 0x3d, 0x22,
            0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x5f, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x31,
            0x22, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3d, 0x22, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e,
            0x31, 0x22, 0x2f, 0x3e, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67,
            0x20, 0x69, 0x64, 0x3d, 0x22, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x5f, 0x53, 0x65, 0x73,
            0x73, 0x69, 0x6f, 0x6e, 0x32, 0x22, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3d, 0x22, 0x53, 0x65,
            0x73, 0x73, 0x69, 0x6f, 0x6e, 0x32, 0x22, 0x2f, 0x3e, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x3c, 0x73,
            0x74, 0x72, 0x69, 0x6e, 0x67, 0x20, 0x69, 0x64, 0x3d, 0x22, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72,
            0x64, 0x5f, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x33, 0x22, 0x20, 0x76, 0x61, 0x6c, 0x75,
            0x65, 0x3d, 0x22, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x33, 0x22, 0x2f, 0x3e, 0x0d, 0x0a,
            0x20, 0x20, 0x20, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x20, 0x69, 0x64, 0x3d, 0x22, 0x74,
            0x61, 0x73, 0x6b, 0x5f, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4d,
            0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3d, 0x22, 0x45,
            0x76, 0x65, 0x6e, 0x74, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67,
            0x65, 0x22, 0x2f, 0x3e, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67,
            0x20, 0x69, 0x64, 0x3d, 0x22, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x54, 0x65, 0x73, 0x74, 0x53, 0x74,
            0x72, 0x75, 0x63, 0x74, 0x75, 0x72, 0x65, 0x64, 0x54, 0x72, 0x61, 0x63, 0x65, 0x30, 0x22, 0x20,
            0x76, 0x61, 0x6c, 0x75, 0x65, 0x3d, 0x22, 0x54, 0x65, 0x73, 0x74, 0x53, 0x74, 0x72, 0x75, 0x63,
            0x74, 0x75, 0x72, 0x65, 0x64, 0x54, 0x72, 0x61, 0x63, 0x65, 0x30, 0x22, 0x2f, 0x3e, 0x0d, 0x0a,
            0x20, 0x20, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x3e,
            0x0d, 0x0a, 0x20, 0x3c, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x3e, 0x0d,
            0x0a, 0x3c, 0x2f, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3e,
            0x0d, 0x0a, 0x3c, 0x2f, 0x69, 0x6e, 0x73, 0x74, 0x72, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74,
            0x69, 0x6f, 0x6e, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x3e, 0x0d, 0x0a
        };

        [TestMethod]
        public void TestFormatString()
        {
            var testPairs = new[]
            {
                new FormatStringTestCase("test", "test", new string[0]),
                new FormatStringTestCase("test%r%n", "test\r\t", new string[0]),
                new FormatStringTestCase("test%%r%n", "test%r\r\t", new string[0]),
                new FormatStringTestCase("test%1r%n", "test100r\r\t", new[] { "100" }),
            };

            foreach (var testCase in testPairs)
            {
                var fm = new EventDefinitionDescription.FormatString(testCase.Input);
                var actual = fm.ApplyValues(testCase.EventData);
                Assert.AreEqual(testCase.ExpectedOutput, actual);
            }
        }

        [TestMethod]
        public unsafe void TestApplicationDataReaderParseDateTime()
        {
            var datetime = DateTime.UtcNow;
            var filetime = datetime.ToFileTimeUtc();

            // DateTime object was incorrectly used. This is needed to handle bad traces from bug #6590047
            var applicationDataReader = new ApplicationDataReader((IntPtr)(int*)&datetime);
            Assert.AreEqual(datetime, applicationDataReader.ReadFileTime());

            applicationDataReader = new ApplicationDataReader((IntPtr)(int*)&filetime);
            Assert.AreEqual(datetime, applicationDataReader.ReadFileTime());
        }

        [TestMethod]
        public void TestManifestLoadingFromByteStream()
        {
            string sequenceToCheck = "<provider name=\"TestEventSource\" guid=\"{0d468d81-a713-4c16-a8a3-a3d0d3535eae}\"";
            string workDirectory = Directory.GetCurrentDirectory();
            ManifestCache manifestCache = new ManifestCache(workDirectory);
            manifestCache.LoadManifest(manifestInBytes);
            string manifestFilePath = Path.Combine(workDirectory, "WFDynMan", "0d468d81-a713-4c16-a8a3-a3d0d3535eae.man");
            // Verify if manifest was generated
            Assert.IsTrue(File.Exists(manifestFilePath), "Dynamic manifest was not created at " + manifestFilePath);
            // Verify the sanity of dynamic manifest
            Assert.IsTrue(File.ReadLines(manifestFilePath).Any(line =>line.Contains(sequenceToCheck)),
                "Dynamic manifest is malformed, check the contents of " + manifestFilePath);
        }

        [TestMethod]
        public void TestPartialManifestInfo()
        {
            PartialManifestInfo partialManifest = new PartialManifestInfo();

            byte[][] eventChunks = new byte[5][];
            eventChunks[0] = new byte[]
            {
                0x01, 0x01, 0x00, 0x5b, 0x05, 0x00, 0x00, 0x00, 0x3c, 0x69, 0x6e, 0x73, 0x74, 0x72, 0x75, 0x6d,
                0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74,
                0x20, 0x78, 0x6d, 0x6c, 0x6e, 0x73, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x73,
                0x63, 0x68, 0x65, 0x6d, 0x61, 0x73, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74,
                0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x77, 0x69, 0x6e, 0x2f, 0x32, 0x30, 0x30, 0x34, 0x2f, 0x30, 0x38,
                0x2f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x3e, 0x0d, 0x0a, 0x20, 0x3c, 0x69, 0x6e, 0x73,
                0x74, 0x72, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x78, 0x6d, 0x6c,
                0x6e, 0x73, 0x3a, 0x78, 0x73, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77,
                0x77, 0x2e, 0x77, 0x33, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x32, 0x30, 0x30, 0x31, 0x2f, 0x58, 0x4d,
                0x4c, 0x53, 0x63, 0x68, 0x65, 0x6d, 0x61, 0x22, 0x20, 0x78, 0x6d, 0x6c, 0x6e, 0x73, 0x3a, 0x78,
                0x73, 0x69, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x77, 0x77, 0x77, 0x2e, 0x77,
                0x33, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x32, 0x30, 0x30, 0x31, 0x2f, 0x58, 0x4d, 0x4c, 0x53, 0x63,
                0x68, 0x65, 0x6d, 0x61, 0x2d, 0x69, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x63, 0x65, 0x22, 0x20, 0x78,
                0x6d, 0x6c, 0x6e, 0x73, 0x3a, 0x77, 0x69, 0x6e, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f,
                0x2f, 0x6d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x73, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f,
                0x73, 0x6f, 0x66, 0x74, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x77, 0x69, 0x6e, 0x2f, 0x32, 0x30, 0x30,
                0x34, 0x2f, 0x30, 0x38, 0x2f, 0x77, 0x69, 0x6e, 0x64, 0x6f, 0x77, 0x73, 0x2f, 0x65, 0x76, 0x65,
                0x6e, 0x74, 0x73, 0x22, 0x3e, 0x0d, 0x0a, 0x20, 0x20, 0x3c, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73,
                0x20, 0x78, 0x6d, 0x6c, 0x6e, 0x73, 0x3d, 0x22, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x73,
                0x63, 0x68, 0x65, 0x6d, 0x61, 0x73, 0x2e, 0x6d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74,
                0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x77, 0x69, 0x6e, 0x2f, 0x32, 0x30, 0x30, 0x34, 0x2f, 0x30, 0x38,
                0x2f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x22, 0x3e, 0x0d, 0x0a, 0x3c, 0x70, 0x72, 0x6f, 0x76,
                0x69, 0x64, 0x65, 0x72, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x54, 0x65, 0x73, 0x74, 0x45,
                0x76, 0x65, 0x6e, 0x74, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x22, 0x20, 0x67, 0x75, 0x69, 0x64,
                0x3d, 0x22, 0x7b, 0x30, 0x64, 0x34, 0x36, 0x38, 0x64, 0x38, 0x31, 0x2d, 0x61, 0x37, 0x31, 0x33,
                0x2d, 0x34, 0x63, 0x31, 0x36, 0x2d, 0x61, 0x38, 0x61, 0x33, 0x2d, 0x61, 0x33, 0x64, 0x30, 0x64,
                0x33, 0x35, 0x33, 0x35, 0x65, 0x61, 0x65, 0x7d, 0x22, 0x20, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72,
                0x63, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x54, 0x65, 0x73, 0x74,
                0x45, 0x76, 0x65, 0x6e, 0x74, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x22, 0x20, 0x6d, 0x65, 0x73,
                0x73, 0x61, 0x67, 0x65, 0x46, 0x69, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x54, 0x65,
                0x73, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x22, 0x20, 0x73,
                0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x3d, 0x22, 0x54, 0x65, 0x73, 0x74, 0x45, 0x76, 0x65, 0x6e, 0x74,
                0x53, 0x6f, 0x75, 0x72, 0x63, 0x65
            };

            eventChunks[1] = new byte[]
            {
                0x01, 0x01, 0x00, 0x5b, 0x05, 0x00, 0x01, 0x00, 0x22, 0x3e, 0x0d, 0x0a, 0x20, 0x3c, 0x74, 0x61,
                0x73, 0x6b, 0x73, 0x3e, 0x0d, 0x0a, 0x20, 0x20, 0x3c, 0x74, 0x61, 0x73, 0x6b, 0x20, 0x6e, 0x61,
                0x6d, 0x65, 0x3d, 0x22, 0x54, 0x65, 0x73, 0x74, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x75, 0x72,
                0x65, 0x64, 0x54, 0x72, 0x61, 0x63, 0x65, 0x30, 0x22, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67,
                0x65, 0x3d, 0x22, 0x24, 0x28, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x74, 0x61, 0x73, 0x6b,
                0x5f, 0x54, 0x65, 0x73, 0x74, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x75, 0x72, 0x65, 0x64, 0x54,
                0x72, 0x61, 0x63, 0x65, 0x30, 0x29, 0x22, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3d, 0x22, 0x34,
                0x32, 0x34, 0x36, 0x37, 0x22, 0x2f, 0x3e, 0x0d, 0x0a, 0x20, 0x20, 0x3c, 0x74, 0x61, 0x73, 0x6b,
                0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x53, 0x6f, 0x75, 0x72,
                0x63, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61,
                0x67, 0x65, 0x3d, 0x22, 0x24, 0x28, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x74, 0x61, 0x73,
                0x6b, 0x5f, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4d, 0x65, 0x73,
                0x73, 0x61, 0x67, 0x65, 0x29, 0x22, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3d, 0x22, 0x36, 0x35,
                0x35, 0x33, 0x34, 0x22, 0x2f, 0x3e, 0x0d, 0x0a, 0x20, 0x3c, 0x2f, 0x74, 0x61, 0x73, 0x6b, 0x73,
                0x3e, 0x0d, 0x0a, 0x20, 0x3c, 0x6f, 0x70, 0x63, 0x6f, 0x64, 0x65, 0x73, 0x3e, 0x0d, 0x0a, 0x20,
                0x3c, 0x2f, 0x6f, 0x70, 0x63, 0x6f, 0x64, 0x65, 0x73, 0x3e, 0x0d, 0x0a, 0x20, 0x3c, 0x6b, 0x65,
                0x79, 0x77, 0x6f, 0x72, 0x64, 0x73, 0x3e, 0x0d, 0x0a, 0x20, 0x20, 0x3c, 0x6b, 0x65, 0x79, 0x77,
                0x6f, 0x72, 0x64, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f,
                0x6e, 0x33, 0x22, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x3d, 0x22, 0x24, 0x28, 0x73,
                0x74, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x5f, 0x53, 0x65,
                0x73, 0x73, 0x69, 0x6f, 0x6e, 0x33, 0x29, 0x22, 0x20, 0x6d, 0x61, 0x73, 0x6b, 0x3d, 0x22, 0x30,
                0x78, 0x31, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x22, 0x2f, 0x3e,
                0x0d, 0x0a, 0x20, 0x20, 0x3c, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x20, 0x6e, 0x61, 0x6d,
                0x65, 0x3d, 0x22, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x32, 0x22, 0x20, 0x6d, 0x65, 0x73,
                0x73, 0x61, 0x67, 0x65, 0x3d, 0x22, 0x24, 0x28, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x6b,
                0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x5f, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x32, 0x29,
                0x22, 0x20, 0x6d, 0x61, 0x73, 0x6b, 0x3d, 0x22, 0x30, 0x78, 0x32, 0x30, 0x30, 0x30, 0x30, 0x30,
                0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x22, 0x2f, 0x3e, 0x0d, 0x0a, 0x20, 0x20, 0x3c, 0x6b, 0x65,
                0x79, 0x77, 0x6f, 0x72, 0x64, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x53, 0x65, 0x73, 0x73,
                0x69, 0x6f, 0x6e, 0x31, 0x22, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x3d, 0x22, 0x24,
                0x28, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x2e, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x5f,
                0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x31, 0x29, 0x22, 0x20, 0x6d, 0x61, 0x73, 0x6b, 0x3d,
                0x22, 0x30, 0x78, 0x34, 0x30, 0x30
            };

            eventChunks[2] = new byte[]
            {
                0x01, 0x01, 0x00, 0x5b, 0x05, 0x00, 0x02, 0x00, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30,
                0x30, 0x22, 0x2f, 0x3e, 0x0d, 0x0a, 0x20, 0x20, 0x3c, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64,
                0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x30, 0x22,
                0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x3d, 0x22, 0x24, 0x28, 0x73, 0x74, 0x72, 0x69,
                0x6e, 0x67, 0x2e, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x5f, 0x53, 0x65, 0x73, 0x73, 0x69,
                0x6f, 0x6e, 0x30, 0x29, 0x22, 0x20, 0x6d, 0x61, 0x73, 0x6b, 0x3d, 0x22, 0x30, 0x78, 0x38, 0x30,
                0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x22, 0x2f, 0x3e, 0x0d, 0x0a, 0x20,
                0x3c, 0x2f, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x73, 0x3e, 0x0d, 0x0a, 0x20, 0x3c, 0x65,
                0x76, 0x65, 0x6e, 0x74, 0x73, 0x3e, 0x0d, 0x0a, 0x20, 0x20, 0x3c, 0x65, 0x76, 0x65, 0x6e, 0x74,
                0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3d, 0x22, 0x30, 0x22, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69,
                0x6f, 0x6e, 0x3d, 0x22, 0x30, 0x22, 0x20, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x3d, 0x22, 0x77, 0x69,
                0x6e, 0x3a, 0x4c, 0x6f, 0x67, 0x41, 0x6c, 0x77, 0x61, 0x79, 0x73, 0x22, 0x20, 0x73, 0x79, 0x6d,
                0x62, 0x6f, 0x6c, 0x3d, 0x22, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65,
                0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x20, 0x74, 0x61, 0x73, 0x6b, 0x3d, 0x22, 0x45,
                0x76, 0x65, 0x6e, 0x74, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67,
                0x65, 0x22, 0x20, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x3d, 0x22, 0x45, 0x76, 0x65,
                0x6e, 0x74, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x41,
                0x72, 0x67, 0x73, 0x22, 0x2f, 0x3e, 0x0d, 0x0a, 0x20, 0x20, 0x3c, 0x65, 0x76, 0x65, 0x6e, 0x74,
                0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3d, 0x22, 0x32, 0x33, 0x30, 0x36, 0x37, 0x22, 0x20, 0x76,
                0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3d, 0x22, 0x30, 0x22, 0x20, 0x6c, 0x65, 0x76, 0x65, 0x6c,
                0x3d, 0x22, 0x77, 0x69, 0x6e, 0x3a, 0x49, 0x6e, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x69, 0x6f,
                0x6e, 0x61, 0x6c, 0x22, 0x20, 0x73, 0x79, 0x6d, 0x62, 0x6f, 0x6c, 0x3d, 0x22, 0x54, 0x65, 0x73,
                0x74, 0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x75, 0x72, 0x65, 0x64, 0x54, 0x72, 0x61, 0x63, 0x65,
                0x30, 0x22, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x3d, 0x22, 0x24, 0x28, 0x73, 0x74,
                0x72, 0x69, 0x6e, 0x67, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x54, 0x65, 0x73, 0x74, 0x53,
                0x74, 0x72, 0x75, 0x63, 0x74, 0x75, 0x72, 0x65, 0x64, 0x54, 0x72, 0x61, 0x63, 0x65, 0x30, 0x29,
                0x22, 0x20, 0x74, 0x61, 0x73, 0x6b, 0x3d, 0x22, 0x54, 0x65, 0x73, 0x74, 0x53, 0x74, 0x72, 0x75,
                0x63, 0x74, 0x75, 0x72, 0x65, 0x64, 0x54, 0x72, 0x61, 0x63, 0x65, 0x30, 0x22, 0x2f, 0x3e, 0x0d,
                0x0a, 0x20, 0x3c, 0x2f, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x3e, 0x0d, 0x0a, 0x20, 0x3c, 0x74,
                0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x3e, 0x0d, 0x0a, 0x20, 0x20, 0x3c, 0x74, 0x65,
                0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x20, 0x74, 0x69, 0x64, 0x3d, 0x22, 0x45, 0x76, 0x65, 0x6e,
                0x74, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x41, 0x72,
                0x67, 0x73, 0x22, 0x3e, 0x0d, 0x0a
            }
                ;
            eventChunks[3] = new byte[]
            {
                0x01, 0x01, 0x00, 0x5b, 0x05, 0x00, 0x03, 0x00, 0x20, 0x20, 0x20, 0x3c, 0x64, 0x61, 0x74, 0x61,
                0x20, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x20,
                0x69, 0x6e, 0x54, 0x79, 0x70, 0x65, 0x3d, 0x22, 0x77, 0x69, 0x6e, 0x3a, 0x55, 0x6e, 0x69, 0x63,
                0x6f, 0x64, 0x65, 0x53, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x22, 0x2f, 0x3e, 0x0d, 0x0a, 0x20, 0x20,
                0x3c, 0x2f, 0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x3e, 0x0d, 0x0a, 0x20, 0x3c, 0x2f,
                0x74, 0x65, 0x6d, 0x70, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x3e, 0x0d, 0x0a, 0x3c, 0x2f, 0x70, 0x72,
                0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x3e, 0x0d, 0x0a, 0x3c, 0x2f, 0x65, 0x76, 0x65, 0x6e, 0x74,
                0x73, 0x3e, 0x0d, 0x0a, 0x3c, 0x2f, 0x69, 0x6e, 0x73, 0x74, 0x72, 0x75, 0x6d, 0x65, 0x6e, 0x74,
                0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3e, 0x0d, 0x0a, 0x3c, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x69, 0x7a,
                0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3e, 0x0d, 0x0a, 0x20, 0x3c, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72,
                0x63, 0x65, 0x73, 0x20, 0x63, 0x75, 0x6c, 0x74, 0x75, 0x72, 0x65, 0x3d, 0x22, 0x65, 0x6e, 0x2d,
                0x55, 0x53, 0x22, 0x3e, 0x0d, 0x0a, 0x20, 0x20, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x54,
                0x61, 0x62, 0x6c, 0x65, 0x3e, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e,
                0x67, 0x20, 0x69, 0x64, 0x3d, 0x22, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x5f, 0x54, 0x65, 0x73, 0x74,
                0x53, 0x74, 0x72, 0x75, 0x63, 0x74, 0x75, 0x72, 0x65, 0x64, 0x54, 0x72, 0x61, 0x63, 0x65, 0x30,
                0x22, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3d, 0x22, 0x54, 0x65, 0x73, 0x74, 0x20, 0x6d, 0x65,
                0x73, 0x73, 0x61, 0x67, 0x65, 0x22, 0x2f, 0x3e, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x3c, 0x73, 0x74,
                0x72, 0x69, 0x6e, 0x67, 0x20, 0x69, 0x64, 0x3d, 0x22, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64,
                0x5f, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x30, 0x22, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65,
                0x3d, 0x22, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x30, 0x22, 0x2f, 0x3e, 0x0d, 0x0a, 0x20,
                0x20, 0x20, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x20, 0x69, 0x64, 0x3d, 0x22, 0x6b, 0x65,
                0x79, 0x77, 0x6f, 0x72, 0x64, 0x5f, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x31, 0x22, 0x20,
                0x76, 0x61, 0x6c, 0x75, 0x65, 0x3d, 0x22, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x31, 0x22,
                0x2f, 0x3e, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x20, 0x69,
                0x64, 0x3d, 0x22, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x5f, 0x53, 0x65, 0x73, 0x73, 0x69,
                0x6f, 0x6e, 0x32, 0x22, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3d, 0x22, 0x53, 0x65, 0x73, 0x73,
                0x69, 0x6f, 0x6e, 0x32, 0x22, 0x2f, 0x3e, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x3c, 0x73, 0x74, 0x72,
                0x69, 0x6e, 0x67, 0x20, 0x69, 0x64, 0x3d, 0x22, 0x6b, 0x65, 0x79, 0x77, 0x6f, 0x72, 0x64, 0x5f,
                0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x33, 0x22, 0x20, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3d,
                0x22, 0x53, 0x65, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x33, 0x22, 0x2f, 0x3e, 0x0d, 0x0a, 0x20, 0x20,
                0x20, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x20, 0x69, 0x64, 0x3d, 0x22, 0x74, 0x61, 0x73,
                0x6b, 0x5f, 0x45, 0x76, 0x65, 0x6e, 0x74, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4d, 0x65, 0x73,
                0x73, 0x61, 0x67, 0x65, 0x22, 0x20
            }
                ;
            eventChunks[4] = new byte[]
            {
                0x01, 0x01, 0x00, 0x5b, 0x05, 0x00, 0x04, 0x00, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3d, 0x22, 0x45,
                0x76, 0x65, 0x6e, 0x74, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x4d, 0x65, 0x73, 0x73, 0x61, 0x67,
                0x65, 0x22, 0x2f, 0x3e, 0x0d, 0x0a, 0x20, 0x20, 0x20, 0x3c, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67,
                0x20, 0x69, 0x64, 0x3d, 0x22, 0x74, 0x61, 0x73, 0x6b, 0x5f, 0x54, 0x65, 0x73, 0x74, 0x53, 0x74,
                0x72, 0x75, 0x63, 0x74, 0x75, 0x72, 0x65, 0x64, 0x54, 0x72, 0x61, 0x63, 0x65, 0x30, 0x22, 0x20,
                0x76, 0x61, 0x6c, 0x75, 0x65, 0x3d, 0x22, 0x54, 0x65, 0x73, 0x74, 0x53, 0x74, 0x72, 0x75, 0x63,
                0x74, 0x75, 0x72, 0x65, 0x64, 0x54, 0x72, 0x61, 0x63, 0x65, 0x30, 0x22, 0x2f, 0x3e, 0x0d, 0x0a,
                0x20, 0x20, 0x3c, 0x2f, 0x73, 0x74, 0x72, 0x69, 0x6e, 0x67, 0x54, 0x61, 0x62, 0x6c, 0x65, 0x3e,
                0x0d, 0x0a, 0x20, 0x3c, 0x2f, 0x72, 0x65, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x73, 0x3e, 0x0d,
                0x0a, 0x3c, 0x2f, 0x6c, 0x6f, 0x63, 0x61, 0x6c, 0x69, 0x7a, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x3e,
                0x0d, 0x0a, 0x3c, 0x2f, 0x69, 0x6e, 0x73, 0x74, 0x72, 0x75, 0x6d, 0x65, 0x6e, 0x74, 0x61, 0x74,
                0x69, 0x6f, 0x6e, 0x4d, 0x61, 0x6e, 0x69, 0x66, 0x65, 0x73, 0x74, 0x3e, 0x0d, 0x0a
            };

            foreach (byte[] chunk in eventChunks)
            {
                byte[] completedManifest = partialManifest.AddChunk(chunk);

                if (completedManifest != null)
                {
                    Assert.IsTrue(completedManifest.SequenceEqual(manifestInBytes));
                }
            }
        }

        private class FormatStringTestCase
        {
            public FormatStringTestCase(string input, string expectedOutput, string[] eventData)
            {
                this.Input = input;
                this.ExpectedOutput = expectedOutput;
                this.EventData = eventData;
            }

            public string Input { get; private set; }
            
            public string ExpectedOutput { get; private set; }

            public string[] EventData { get; private set; }
        }

        [TestMethod]
        public void TestMultipleProvidersInManifest()
        {
            var manifestWithMultipleProviders = @"<?xml version='1.0' encoding='utf-8' standalone='yes'?>
                        <assembly xmlns=""urn: schemas - microsoft - com:asm.v3"">
                            <instrumentation>
                                <events xmlns = ""http://schemas.microsoft.com/win/2004/08/events""> 
                                   <provider
                                      guid = ""{cbd93bc2-71e5-4566-b3a7-595d8eeca6e8}""
                                      message = ""$(string.ms1654592029.0)""
                                      messageFileName = ""%ProgramFiles%\Windows Fabric\bin\Fabric\Fabric.Code\FabricResources.dll""
                                      name = ""Microsoft-ServiceFabric""
                                      resourceFileName = ""%ProgramFiles%\Windows Fabric\bin\Fabric\Fabric.Code\FabricResources.dll""
                                      symbol = ""Microsoft_ServiceFabric""
                                      >
                                      <events>
                                              <event
                                                  channel=""Admin""
                                                  keywords = ""Default""
                                                  level = ""win:Error""
                                                  message = ""$(string.ns37.0)""
                                                  opcode = ""win:Info""
                                                  symbol = ""Event_Common_ErrorText""
                                                  task = ""Common""
                                                  template = ""ntid_256""
                                                  value = ""256""
                                                  />
                                      </events>
                                      <templates>
                                          <template tid=""ntid_256"">
                                            <data
                                                inType = ""win:UnicodeString""
                                                name = ""id""
                                                outType = ""xs:string""
                                                />
                                          </template>
                                      </templates>
                                      <maps>
                                          <valueMap name=""AccessStatus"">
                                            <map
                                                message = ""$(string.ns0.1)""
                                                value = ""0""
                                                />
                                          </valueMap>
                                      </maps>
                                    </provider>
                                    <provider
                                      guid = ""{c4a5f2a0-58bb-46be-a1b1-a9ac70c32af7}""
                                      message = ""$(string.ms1654592029.0)""
                                      messageFileName = ""%ProgramFiles%\Windows Fabric\bin\Fabric\Fabric.Code\FabricResources.dll""
                                      name = ""Microsoft-ServiceFabric""
                                      resourceFileName = ""%ProgramFiles%\Windows Fabric\bin\Fabric\Fabric.Code\FabricResources.dll""
                                      symbol = ""Microsoft_ServiceFabric""
                                      >
                                      <events>
                                              <event
                                                  channel=""Admin""
                                                  keywords = ""Default""
                                                  level = ""win:Error""
                                                  message = ""$(string.ns37.0)""
                                                  opcode = ""win:Info""
                                                  symbol = ""Event_Common_ErrorText""
                                                  task = ""Common""
                                                  template = ""ntid_256""
                                                  value = ""256""
                                                  />
                                      </events>
                                      <templates>
                                          <template tid=""ntid_256"">
                                            <data
                                                inType = ""win:UnicodeString""
                                                name = ""id""
                                                outType = ""xs:string""
                                                />
                                          </template>
                                      </templates>
                                      <maps>
                                          <valueMap name=""AccessStatus"">
                                            <map
                                                message = ""$(string.ns0.1)""
                                                value = ""0""
                                                />
                                          </valueMap>
                                      </maps>
                                    </provider>
                                </events>
                            </instrumentation>
                            <localization>
                                <resources culture=""en - US"">
                                    <stringTable >
                                      <string
                                        id = ""ns0.1""
                                        value = "" ""
                                        />
                                      <string
                                        id=""ns37.0""
                                        value = ""P""
                                       />
                                    </stringTable>
                                </resources>
                            </localization>
                        </assembly>
                        ";

            ManifestLoader loader = new ManifestLoader();
            var description = loader.LoadManifest(new MemoryStream(Encoding.ASCII.GetBytes(manifestWithMultipleProviders)));
            Assert.IsTrue(description.Providers.Count == 2, "Not able to parse two proiders in same manifest.");
        }
    }
}